

// ajax二次封装 (type url,params)
// 目的是将所有的接口  都统一到一个js文件中

function request(type = "get", url = "", params = {}) {
    return new Promise(function (resolve, reject) {
        $.ajax({
            type: type,
            url: url,
            data: {
                // user: user,
                // pwd,
                // phone,
                // email,
                ...params,
            },
            dataType: "json",
            success: function (result) {
                resolve(result);
            }
        })
    })
}

const register = params => request("post", "../php/register.php", params);
const login = params => request("post", "../php/login.php", params);
const requestData = params => request("get", "../php/searchGrades.php", params);

const searchAllGoods = params => request("get", "../php/searchAllGoods.php", params);
const searchGoods = params => request("get", "../php/searchGoods.php", params);
const searchGoodsById = params => request("get", "../php/searchGoodsById.php", params);

const addToShoppingCar = params => request("post", "../php/addToShoppingCar.php", params);





